﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StudentsClassDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Faculty faculty= Faculty.GenerateRandomChair();
            faculty.PrintChairToConsole();
        }
    }
    class Group
    {
        public string Name;
        public List<Student> students = new List<Student>();

        public static int groupCount;

        public static Group GenerateRandomGroup()
        {
            groupCount++;
            Group group = new Group();
            group.Name = "Group" + Group.groupCount;
            for (int i = 0; i < 5; i++)
            {
                Student student = Student.GenerateRandomStudent();
                group.students.Add(student);
            }
            return group;
        }

        public void PrintGroupToConsole()
        {
            Console.WriteLine("***************");
            Console.WriteLine("Group: {0}", Name);
            Console.WriteLine("***************");
            foreach (var student in students)
            {
                student.PrintStudentInfoToConsole();
                Console.WriteLine("--------------");
            }
            Console.WriteLine("================");
        }

    }
    class Chair
    {
        public string Name;
        public List<Group> groups = new List<Group>();

        public static int chairCount = 100;

        public static Chair GenerateRandomChair()
        {
            Chair chair = new Chair();
            chair.Name = "Chair" + chairCount++;
            for (int i = 0; i < 3; i++)
            {
                Group grp = Group.GenerateRandomGroup();
                chair.groups.Add(grp);
            }
            return chair;
        }

        public void PrintChairToConsole()
        {
            Console.WriteLine("++++++++++++++++++++++");
            Console.WriteLine("Chair Name: {0}", Name);
            Console.WriteLine("++++++++++++++++++++++");
            foreach (var group in groups)
            {
                group.PrintGroupToConsole();
            }
        }
    }
    namespace FacultyExample
    {
        class Student
        {
            public string FirstName;
            public string LastName;
            public DateTime DateOfBirth;
            public List<int> Marks = new List<int>();

            public static Random rndGenerator = new Random();
            public static int StudentCount;

            public void GenerateRandomStudentParameters()
            {
                StudentCount++;
                FirstName = "Вася";
                LastName = Student.StudentCount.ToString();
                DateOfBirth = new DateTime(Student.rndGenerator.Next(1990, 2012), Student.rndGenerator.Next(1, 13), Student.rndGenerator.Next(1, 21));
                for (int i = 0; i < 5; i++)
                {
                    int mark = Student.rndGenerator.Next(1, 101);
                    Marks.Add(mark);
                }
            }

            public static Student GenerateRandomStudent()
            {
                Student.StudentCount++;
                Student student = new Student();
                student.FirstName = "Вася";
                student.LastName = Student.StudentCount.ToString();
                student.DateOfBirth = new DateTime(Student.rndGenerator.Next(1990, 2012), Student.rndGenerator.Next(1, 13), Student.rndGenerator.Next(1, 21));
                for (int i = 0; i < 5; i++)
                {
                    int mark = Student.rndGenerator.Next(1, 101);
                    student.Marks.Add(mark);
                }
                return student;
            }

            public void PrintStudentMarksToConsole()
            {
                foreach (var mark in Marks)
                {
                    Console.WriteLine(mark);
                }
            }

            public void PrintStudentInfoToConsole()
            {
                Console.WriteLine("First Name: {0}", FirstName);
                Console.WriteLine("Last Name: {0}", LastName);
                Console.WriteLine("Birthday: {0}", DateOfBirth.ToString("dd/MM/yyyy"));
            }

            public double CalculateAvgMark()
            {
                return Marks.Average();
            }

        }
    }
    class Faculty
    {
        public string Name;
        public List<Chair> chair = new List<Chair>();

        public static int facultyCount;

        public static Faculty GenerateRandomFaculty()
        {
            facultyCount;
            Faculty faculty = new Faculty();
            faculty.Name = "Faculty" + Faculty.FacultyCount;
            for (int i = 0; i < 3; i++)
            {
                Student student = Student.GenerateRandomStudent();
                chair.chair.Add(chair);
            }
            return faculty;
        }

        public void PrintFacultyToConsole()

        {
            Console.WriteLine("++++++++++++++++++++++");
            Console.WriteLine("Faculty Name: {0}", Name);
            Console.WriteLine("++++++++++++++++++++++");
            foreach (var chair in chairs)
            {
                Faculty.PrintFacultyToConsole();
            }
        }
    }
}

